package com.wlient.basic.Thread.test;

import java.util.List;

public class ListNode {
      int val;
      ListNode next;
      ListNode(int x) { val = x; }


    class Solution {
        public ListNode deleteNode(ListNode head, int val) {
            ListNode q = head;
            ListNode p = q.next;
            if(head ==null){
                return null;
            }
            if(head.val == val){
                head = head.next;
            }
            while(p !=null){
                if(p.val == val){
                    q.next = p.next;
                }
                q = p;
                p = p.next;
            }
            return head;

        }
    }
 }

